home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / circuits / irsim_ta.z / irsim_ta / irsim / src / include / net.h < prev   
Encoding:
C/C++ Source or Header  |  1990-09-13  |  10.5 KB  |  307 lines

  1. /* 
  2.  *     ********************************************************************* 
  3.  *     * Copyright (C) 1988, 1990 Stanford University.                     * 
  4.  *     * Permission to use, copy, modify, and distribute this              * 
  5.  *     * software and its documentation for any purpose and without        * 
  6.  *     * fee is hereby granted, provided that the above copyright          * 
  7.  *     * notice appear in all copies.  Stanford University                 * 
  8.  *     * makes no representations about the suitability of this            * 
  9.  *     * software for any purpose.  It is provided "as is" without         * 
  10.  *     * express or implied warranty.  Export of this software outside     * 
  11.  *     * of the United States of America may require an export license.    * 
  12.  *     ********************************************************************* 
  13.  */
  14.  
  15.  
  16. /* header for event driven mosfet simulator.  Chris Terman (6/84) */
  17.  
  18. typedef struct Event    *evptr;
  19. typedef struct Node    *nptr;
  20. typedef struct Trans    *tptr;
  21. typedef struct Input    *iptr;
  22. typedef struct Tlist    *lptr;
  23. typedef struct HistEnt    *hptr;
  24. typedef struct Bits     *bptr;
  25. typedef struct thevenin *Thev;
  26.  
  27.  
  28. struct Tlist
  29.   {
  30.     lptr    next;        /* next list element */
  31.     tptr    xtor;        /* txtor connected to this node */
  32.   };
  33.  
  34.  
  35. struct Event
  36.   {
  37.     evptr    flink, blink;    /* doubly-linked event list */
  38.     evptr    nlink;        /* link for list of events for this node */
  39.     nptr     enode;        /* node this event is all about */
  40.     union
  41.       {
  42.     nptr  cause;        /* node which caused this event to happen */
  43.     hptr  hist;        /* ptr. to history entry that queued this */
  44.     long  oldt;        /* original time for delayed events */
  45.       } p;
  46.     long     ntime;        /* time, in DELTAs, of this event */
  47.     long     rtime;        /* rise/fall time, in DELTAs */
  48.     short    delay;        /* delay associated with this event */
  49.     char     eval;        /* new value */
  50.     char     type;        /* type of event (for incremental only) */
  51.   };
  52.  
  53. typedef unsigned long  Ulong;
  54. typedef unsigned int   Uint;
  55. typedef int (*ifun)();
  56.  
  57. typedef struct
  58.   {
  59.     short    delay;              /* delay from input */
  60.     short    rtime;              /* rise/fall time */
  61.   } RegTimes;
  62.  
  63. typedef struct
  64.   {
  65.     Uint    delay : 12;              /* delay from input */
  66.     Uint    rtime : 10;              /* rise/fall time */
  67.     Uint    ptime : 10;              /* punt time */
  68.   } PuntTimes;
  69.  
  70. typedef struct HistEnt
  71.   {
  72.     hptr     next;                  /* next transition in history */
  73.     Ulong    time  : sizeof(Ulong) * 8 - 4;   /* time of transition */
  74.     Uint     inp   : 1;                  /* 1 if node became an input */
  75.     Uint     punt  : 1;                  /* 1 if this event was punted */
  76.     Uint     val   : 2;                  /* value: HIGH, LOW, or X */
  77.     union
  78.       {
  79.     RegTimes    r;
  80.     PuntTimes   p;
  81.       } t;
  82.   } HistEnt;
  83.  
  84.  
  85. #define    MAX_TIME    ( (~((Ulong) 0)) >> 4 )        /* a huge time */
  86.  
  87. extern    Ulong  max_time;        /* contains MAX_TIME (compiler bug) */
  88.  
  89.  
  90. struct Node
  91.   {
  92.     nptr     nlink;    /* sundries list */
  93.     evptr    events;    /* charge sharing event */
  94.     lptr     ngate;    /* list of xtors w/ gates connected to this node */
  95.     lptr     nterm;    /* list of xtors w/ src/drn connected to this node */
  96.     nptr     hnext;    /* link in hash bucket */
  97.     float    ncap;    /* capacitance of node in pf */
  98.     float    vlow;    /* low logic threshold for node, normalized units */
  99.     float    vhigh;    /* high logic threshold for node, normalized units */
  100.     short    tplh;    /* low to high transition time in DELTA's */
  101.     short    tphl;    /* high to low transition time in DELTA's */
  102.     union
  103.       {
  104.     Ulong  time;    /* time, in DELTAs, of last transistion */
  105.     float  cap;    /* incremental capacitance during net-changes */
  106.     evptr  event;    /* non threaded events in incremental simulation */
  107.       } c;
  108.     union
  109.      {
  110.     nptr  cause;    /* node which caused last transition of this node */
  111.     hptr  punts;    /* punted events during incremental simulation */
  112.     tptr  tran;    /* transistor into which stacked xtors were merged */
  113.      } t;
  114.     int      npot;    /* current potential */
  115.     long     nflags;    /* flag word (see defs below) */
  116.     char     *nname;    /* ascii name of node */
  117.     union
  118.       {
  119.     Thev  thev;    /* used to temporarily store the thevenin structure */
  120.     nptr  next;    /* used to build node lists during net changes */
  121.     tptr  tran;    /* used to mark parallel transistors */
  122.       } n;
  123.     HistEnt  head;    /* first entry in transition history */
  124.     hptr     curr;    /* ptr. to current history entry */
  125. #ifdef FAULT_SIM
  126.     HistEnt  hchange;    /* special entry to avoid changing the history */ 
  127. #endif
  128.   };
  129.  
  130.  
  131. typedef struct        /* same as Res_1 but indexed dynamic resists */
  132.   {
  133.     float  dynres[ 2 ];        /* dynamic resistances [R_LOW - R_MAX] */
  134.     float  rstatic;        /* static resistance of transistor */
  135.   } Resists;
  136.  
  137. #define    R_LOW        0        /* dynamic low resiatance index */
  138. #define    R_HIGH        1        /* dynamic high resiatance index */
  139.  
  140. #define    dynlow        dynres[ R_LOW ]    /* abbrevations for above */
  141. #define    dynhigh        dynres[ R_HIGH ]
  142.  
  143.  
  144. typedef union
  145.   {
  146.     Thev  r;
  147.     tptr  t;
  148.     int   i;
  149.  } TCache;
  150.  
  151.  
  152. struct Trans
  153.   {
  154.     nptr     gate, source, drain;    /* nodes to which trans is connected */
  155.     TCache   scache, dcache;         /* caches to remember src/drn values */
  156.     char     ttype;             /* type of transistor */
  157.     char     state;             /* cache to remember current state */
  158.     char     tflags;              /* transistor flags */
  159.     char     n_par;             /* index into parallel list */
  160.     Resists  r;                 /* transistor resistances */
  161.     long     x, y;             /* position in the layout (optional) */
  162.     tptr     tlink;             /* next txtor in position hash table */
  163.   };
  164.  
  165.  
  166. typedef struct Bits
  167.   {
  168.     bptr    next;        /* next bit vector in chain */
  169.     char    *name;        /* name of this vector of bits */
  170.     int     traced;        /* <>0 if this vector is being traced */
  171.     int     nbits;        /* number of bits in this vector */
  172.     nptr    nodes[1];        /* pointers to the bits (nodes) */
  173.   } Bits;
  174.  
  175.  
  176.     /* linked list of inputs */
  177. struct Input
  178.   {
  179.     iptr    next;        /* next element of list */
  180.     nptr    inode;        /* pointer to this input node */
  181.   };
  182.  
  183.  
  184.     /* transistor types (ttype) */
  185. #define    NCHAN        0    /* n-channel enhancement */
  186. #define    PCHAN        1    /* p-channel enhancement */
  187. #define    DEP        2    /* depletion */
  188. #define    PULLUP        3    /* pullup => depletion with source == gate */
  189. #define    RESIST        4    /* simple two-terminal resistor */
  190.  
  191. #define    ALWAYSON    0x06    /* transistors not affected by gate logic */
  192. #define    GATELIST    0x08    /* set if gate of xistor is a node list */
  193. #define    DEP_RES        0x10    /* set if DEP was changed to RESIST */
  194. #define    TCAP        0x20    /* transistor capacitor (source == drain) */
  195. #define    STACKED        0x40    /* transistor was stacked into gate list */
  196. #define    ORED        0x80    /* result of or'ing parallel transistors */
  197.  
  198. #define    NTTYPES        5    /* number of transistor types defined */
  199.  
  200. #define    NOT_CONN        ( TCAP | STACKED )    /* not connected */
  201. #define    BASETYPE( T )        ( (T) & 0x07 )
  202.  
  203.     /* transistor states (state)*/
  204. #define    OFF        0    /* non-conducting */
  205. #define    ON        1    /* conducting */
  206. #define    UNKNOWN        2    /* unknown */
  207. #define    WEAK        3    /* weak */
  208.  
  209.     /* transistor temporary flags (tflags) */
  210. #define    CROSSED        0x01    /* Mark for crossing a transistor */
  211. #define BROKEN        0x02    /* Mark a broken transistor to avoid loop */
  212. #define    PBROKEN        0x04    /* Mark as broken a parallel transistor */
  213. #define    PARALLEL    0x08    /* Mark as being a parallel transistor */
  214. #define    ACTIVE_T    0x10    /* incremental status of transistor */
  215.  
  216.     /* figure what's on the *other* terminal node of a transistor */
  217. #define    other_node( T, N )    ((T)->source == (N) ? (T)->drain : (T)->source)
  218.  
  219.     /* node potentials */
  220. #define    LOW        0    /* low low */
  221. #define    X        1    /* unknown, intermediate, ... value */
  222. #define    HIGH        3    /* logic high */
  223. #define    N_POTS        4    /* number of potentials [LOW-HIGH] */
  224.  
  225. #define    DECAY        4    /* waiting to decay to X (only in events) */
  226.  
  227.     /* possible values for nflags */
  228. #define    OLD_VAL        0x000003
  229. #define    WATCHED        0x000004
  230. #define    INPUT        0x000008
  231. #define    POWER_RAIL    0x000010
  232. #define    ALIAS        0x000020
  233. #define    MERGED        0x000040
  234. #define    STOPONCHANGE    0x000080
  235. #define    USERDELAY    0x000100
  236. #define    VISITED        0x000200
  237.  
  238. #define    ALIASED        0x000400    /* another node is aliased to this */
  239. #define    DELETED        0x000800    /* unused now */
  240.  
  241. #define    H_INPUT        0x001000    /* node is in high input list */
  242. #define    L_INPUT        0x002000    /* node is in low input list */
  243. #define    U_INPUT        0x003000    /* node is in U input list */
  244. #define    X_INPUT        0x004000    /* node is in X input list */
  245. #define    OLD_INPUT    X_INPUT        /* input has been processed already */
  246.  
  247. #define    INPUT_MASK        ( H_INPUT | L_INPUT | X_INPUT | U_INPUT )
  248. #define    IsInList( flg )        ( (flg) & INPUT_MASK )
  249. #define    INPUT_NUM( flg )    ( ((flg) & INPUT_MASK) >> 12 )
  250.  
  251. #define    CHANGED        0x080000    /* node is affected by a net change */
  252. #define    DEVIATED    0x100000    /* node's state differs from hist */
  253. #define    STIM        0x200000    /* node is used as stimuli */
  254. #define    ACTIVE_CL    0x400000    /* node is in an active cluster */
  255. #define    WAS_ACTIVE    0x800000    /* set if node was ever active */
  256.  
  257. #define    DEV_BIT        20        /* DEVIATED bit position */
  258.  
  259.     /* resistance types */
  260. #define    STATIC        0    /* static resistance */
  261. #define    DYNHIGH     1    /* dynamic-high resistance */
  262. #define    DYNLOW      2    /* dynamic-low resistance */
  263. #define    POWER        3    /* resist. for power calculation (unused) */
  264. #define    R_TYPES        3    /* number of resistance contexts */
  265.  
  266.     /* Define TRUE and FALSE values */
  267. #define TRUE  1
  268. #define FALSE 0
  269.  
  270.     /* Possible simulator status */
  271. #define    NORM_SIM        0        /* normal mode */
  272. #define    INCR_SIM        01        /* incremental mode */
  273. #define    OUT_OF_MEM        02        /* out of memory flag */
  274.  
  275.     /* Event Types (for incremental simulation only) */
  276.  
  277. #define    IS_INPUT        0x1        /* event makes node input */
  278. #define    IS_XINPUT        0x2        /* event terminates input */
  279.  
  280. #define    REVAL            0x0        /* result of re-evaluation */
  281. #define    DECAY_EV        0x1        /* node is decaying to X */
  282. #define    PUNTED            0x3        /* previously punted event */
  283.  
  284.     /* events > THREAD are NOT threaded into node structure */
  285. #define    THREAD            0x3
  286.  
  287. #define    PENDING            0x4        /* pending from last run */ 
  288. #define    STIMULI            0x8        /* self-schedulled stimuli */
  289. #define    STIM_INP        ( STIMULI | IS_INPUT )
  290. #define    STIM_XINP        ( STIMULI | IS_XINPUT )
  291.  
  292. #define    CHECK_PNT        0x10        /* next change in history */
  293. #define    INP_EV            ( CHECK_PNT | IS_INPUT )
  294. #define    XINP_EV            ( CHECK_PNT | IS_XINPUT )
  295. #define    DELAY_CHK        0x20        /* delayed CHECK_PNT */
  296. #define    DELAY_EV        0x40        /* last REVAL was delayed */
  297.  
  298. #define    CHNG_MODEL        0x80        /* change evaluation model */
  299.  
  300.  
  301.     /* Conversion macros between various time units */
  302. #define    d2ns( D )        ( (D) * 0.1 )        /* deltas to ns */
  303. #define    d2ps( D )        ( (D) * 100.0 )        /* deltas to ps */
  304. #define    ns2d( N )        ( (N) * 10.0 )        /* ns to deltas */
  305. #define    ps2d( P )        ( (P) * 0.01 )        /* ps to deltas */
  306. #define    ps2ns( P )        ( (P) * 0.001 )        /* ps to ns */
  307.